package com.itheima.Jiuye13;

public class MaipiaoTest implements Runnable{
    private int ticket = 100;
    //private String  a = " ";
    @Override
    public void run() {
        while (true) {
            synchronized (this){
                if (ticket <= 0){
                    break;
                }else {
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    ticket --;
                    System.out.println(Thread.currentThread().getName()+"在卖票，还剩"+ticket+"张票");
                }
            }

        }
    }
}
